<template>
	<view class="indexs">
		<view class="header header_lan" :style="'padding-top: ' + navH + 'px;'">
			<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
				<view class="index_h_cont3">
					<view class="index_wenben_img" @tap="jumpzuo"><image :src="imgUrl + '/dzx_img22.png'" mode="widthFix"></image></view>
					<view class="index_wenben baise">{{ $t('page_user_modify.tzsqxg') }}</view>
				</view>
			</view>
			<view class="coloe_title">s</view>
		</view>
		<view class="index_center" :style="'padding-top:' + (navH + 50) + 'px;padding-bottom: 120rpx;'">
			<view class="baoguo_center">
				<view class="baoguo_item2">
					<view class="baoguo_item2_cont">
						<view class="baoguo_item2_cont_l">
							<image :src="imgUrl + '/dzx_img29.png'"></image>
							<text>{{ $t('page_user_modify.Real_name') }}</text>
						</view>
						<view class="baoguo_item2_cont_r">
							<input type="text" data-field="truename" @input="bindInput" :value="form['truename']" :placeholder="$t('page_user_modify.p_Real_name')" />
						</view>
					</view>
					<view class="baoguo_item2_cont">
						<view class="baoguo_item2_cont_l">
							<image :src="imgUrl + '/dzx_img29.png'"></image>
							<text>{{ $t('page_user_modify.idcard') }}</text>
						</view>
						<view class="baoguo_item2_cont_r">
							<input type="text" data-field="idcard" @input="bindInput" :value="form['idcard']" :placeholder="$t('page_user_modify.p_idcard')" />
						</view>
					</view>
					<view class="baoguo_item2_cont">
						<view class="baoguo_item2_cont_l">
							<image :src="imgUrl + '/dzx_img29.png'"></image>
							<text>{{ $t('page_user_modify.phone') }}</text>
						</view>
						<view class="baoguo_item2_cont_r">
							<input type="text" data-field="mobile" @input="bindInput" :value="form['mobile']" :placeholder="$t('page_user_modify.placeholder')" />
						</view>
					</view>
					<view class="verify-reason">{{ $t('page_user_modify.Reason_audit') }}:{{ reason }}</view>
					<view class="baoguo_btns">
						<view class="baoguo_btns_posi">
							<view class="baoguo_btn" @tap="sumbit">{{ $t('page_user_modify.resubmit') }}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
// pages/shouye/shouye_zkc/shouye_zkc.js
const app = getApp();

let request = require('../../utils/require');

export default {
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData.top,
			imgUrl: app.globalData.imgUrl,
			form: {
				truename: '',
				idcard: '',
				mobile: ''
			},
			reason: ''
		};
	},
	/**
	 * 生命周期函数--监听页面加载
	 */ onLoad() {
		var that = this;

	},
	onShow() {
		this.getVerify();
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {},
	methods: {
		jumpzuo() {
			uni.navigateBack();
		},
		bindInput(e) {
			var form = this.form;
			var field = e.currentTarget.dataset.field;
			form[field] = e.detail.value;
			this.form = form;
		},
		setFieldForm(form) {
			console.log(form, 'form');
			for (var l in this.form) {
				this.form[l] = form[l];
			}
		},
		getVerify() {
			var form = [];
			var token = uni.getStorageSync('token');
			request.post(`index.php?s=/api/sharp.index/apply_detail&wxapp_id=` + uni.getStorageSync('web_id') + '&token=' + token, form).then(res => {
				if (res.data.code == 1) {
					this.reason = res.data.data.detail['reason'];
					console.log(this.reason, 'reason');
					this.setFieldForm(res.data.data.detail);
				} else {
					uni.showToast({
						icon: 'none',
						title: res.data.msg
					});
				}
			});
		},
		sumbit() {
			var form = this.form;
			if (!this.sumbitCheck(form)) {
				uni.showToast({
					icon: 'none',
					title: '请填写完必填资料'
				});
				return;
			}
			var that = this;
			uni.showLoading({
				title: '提交资料中'
			});
			form['token'] = uni.getStorageSync('token');
			request.post(`index.php?s=/api/sharp.index/apply&wxapp_id=` + uni.getStorageSync('web_id') + '&type=resubmit', form).then(res => {
				uni.hideLoading();
				if (res.data.code == 1) {
					uni.showToast({
						title: res.data.msg
					});
				} else {
					uni.showToast({
						icon: 'none',
						title: res.data.msg
					});
				}
			});
		},
		sumbitCheck(form) {
			for (var _k in form) {
				if (form[_k] == '') {
					return false;
				}
			}
			return true;
		}
	}
};
</script>

<style>
@import './user.css';
.verify-reason {
	height: 30px;
	line-height: 30px;
	font-size: 13px;
	color: #ff2638;
}
</style>
